package com.dony.order.service.impl;

import com.dony.common.utils.DateUtils;
import com.dony.common.utils.StringUtils;
import com.dony.order.domain.OperationRecord;
import com.dony.order.mapper.OperationRecordMapper;
import com.dony.order.service.IOperationRecordService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import static com.dony.common.utils.SecurityUtils.getNickName;
import static com.dony.common.utils.SecurityUtils.getUsername;

/**
 *
 * @author dony
 * @date 2022-09-07
 */
@Slf4j
@Service("operationRecordService")
public class OperationRecordServiceImpl extends MPJBaseServiceImpl<OperationRecordMapper, OperationRecord> implements IOperationRecordService {

    @Override
    public boolean addRecord(String orderSn, String type, String detail) {
        if (StringUtils.isNotEmpty(orderSn)&&StringUtils.isNotEmpty(type)) {
            OperationRecord record = new OperationRecord();
            record.setOrderSn(orderSn);
            record.setType(type);
            record.setDetail(detail);
            record.setCreateBy(getNickName());
            record.setCreateTime(DateUtils.getNowDate());
            this.save(record);
        }
        return false;
    }
}
